let index_fn = async (ctx, next) => {
    ctx.body = `
    <form action="/login" method="post">
        <div>
            <label for="">用户名：</label>
        </div>
        <div>
            <input type="text" name="username">
        </div>
        <div>
            <label for="">密码：</label>
        </div>
        <div>
            <input type="password" name="password">
        </div>
        <div>
            <input type="submit" value="登录">
        </div>
    </form>
    `;
};

let home_fn = async (ctx, next) => {
    ctx.body = '欢迎来到我的主页';
};

let login_fn = async (ctx, next) => {
    let username = ctx.request.body.username;
    let password = ctx.request.body.password;
    console.log(username);
    console.log(password);

    if (username === 'user' && password === '123456') {
        ctx.redirect('/home');
    } else {
        ctx.body = '用户名或密码错误';
    };
};

module.exports = {
    '/': ['get', index_fn],
    '/login': ['post', login_fn],
    '/home': ['get', home_fn]
};